package com.think.teaching.model;

import java.io.Serializable;

import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.think.common.model.Result;
import com.think.common.model.ResultCode;
import com.think.common.utils.Common;

/**
 * <p>
 * 资源
 * </p>
 *
 * @author think
 * @since 2020-08-12
 */
public class Asset extends BaseModel<Asset> {

    private static final long serialVersionUID=1L;
    
    public static final int IMAGE_ASSET  = 1;
    
    public static final int VIDEO_ASSET  = 2;

    public static final int DOCUMENT_ASSET = 3;
    
    public static final int OTHER_ASSET = 4;


    /**
     * 主键
     */
    @TableId(value = "id", type = IdType.AUTO)
    private Integer id;

    /**
     * 资源路径
     */
    private String url;

    /**
     * 资源类型
     */
    private Integer type;

   


    public Integer getId() {
        return id;
    }

    public void setId(Integer id) {
        this.id = id;
    }

    public String getUrl() {
        return url;
    }

    public void setUrl(String url) {
        this.url = url;
    }

    public Integer getType() {
        return type;
    }

    public void setType(Integer type) {
        this.type = type;
    }

    
    @Override
    protected Serializable pkVal() {
        return this.id;
    }
    
    

    @Override
	public Result CheckObjectComplete() {
		// TODO Auto-generated method stub
    	if (type <IMAGE_ASSET || type>OTHER_ASSET) {
			return Result.failure(ResultCode.ASSET_TYPE_NOT_DEFINE);
		}
    	createdBy = Common.GetCurrentAuthor().getUserId();
		return super.CheckObjectComplete();
	}

	@Override
    public String toString() {
        return "Asset{" +
        "id=" + id +
        ", url=" + url +
        ", type=" + type +
        ", createdBy=" + createdBy +
        ", createdTime=" + createdTime +
        ", updatedBy=" + updatedBy +
        ", updatedTime=" + updatedTime +
        ", delflag=" + delflag +
        ", state=" + state +
        "}";
    }
}
